package com.wanmait.recruitment.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.recruitment.mapper.WebMenuMapper;
import com.wanmait.recruitment.pojo.WebMenu;
import com.wanmait.recruitment.service.WebMenuService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class WebMenuServiceImpl implements WebMenuService {
    @Resource
    private WebMenuMapper webMenuMapper;


    @Override
    public void insert(WebMenu object) {
        webMenuMapper.insertWebMenu(object);

    }

    @Override
    public void delete(Integer id) {
        webMenuMapper.delete(id);

    }

    @Override
    public void delete(String ids) {
        webMenuMapper.batchDelete(ids);

    }

    @Override
    public void update(WebMenu object) {
        webMenuMapper.update(object);


    }

    @Override
    public void update(WebMenu object, Integer id) {

    }

    @Override
    public WebMenu findById(Integer id) {
        return null;
    }

    @Override
    @Cacheable("webMenuCache")
    public List<WebMenu> findAll() {
        return webMenuMapper.selectList();
    }

    @Override
    public List<WebMenu> findAll(WebMenu object) {
        return null;
    }

    @Override
    public PageInfo<WebMenu> findPage(int pageNum, int pageSize) {

        PageHelper.startPage(pageNum,pageSize);
        List<WebMenu>webMenuList=webMenuMapper.selectList();
        PageInfo<WebMenu>pageInfo=new PageInfo<>(webMenuList);
        return pageInfo;

    }
    @Override
    public PageInfo<WebMenu> findPage(int pageNum, int pageSize,String titile) {

        PageHelper.startPage(pageNum,pageSize);
        List<WebMenu>webMenuList=webMenuMapper.selectListByName(titile);
        PageInfo<WebMenu>pageInfo=new PageInfo<>(webMenuList);
        return pageInfo;

    }
}
